/**
 * 添加或者修改页面
 */
var HxOrderOutInfoDlg = {
    data: {
        customerId: "",
        customerName: "",
        orderState: "",
        peisongTime: "",
        orderOutNumber: "",
        orderType: "",
        setUnitId: "",
        setUnit: "",
        getWarehouseId: "",
        getWarehouse: "",
        getUnitId: "",
        getUnit: "",
        goodsNum: "",
        outNum: "",
        zNum: "",
        lNum: "",
        putVolume: "",
        createUserName: "",
        submitUserName: "",
        revokeUserName: "",
        createTime: "",
        submitTime: "",
        revokeTime: "",
        completeTime: "",
        notes: "",
        associationOrder: "",
        associationOrderType: "",
        goodsId: "",
        goodsName: "",
        goodsNumber: "",
        goodsPcode69: "",
        goodsSpecs: "",
        unit: "",
        rate: "",
        psNum: "",
        v1: "",
        v2: "",
        v3: "",
        v4: "",
        v5: "",
        v6: "",
        deptId: "",
        deliverId: ""
    }
};
var BasicPutgoodsInfoDlg = {
    data: {
        id: "",
        dictId: "",
        putgoodsCustomerId: "",
        putgoodsOperateName: "",
        putgoodsName: "",
        unitNumber: "",
        unitType: ""
    }
};
var HxStorageStockInfoDlg = {
    data: {
        id: "",
        positionId: "",
        positionNumber: "",
        goodsId: "",
        goodsName: "",
        goodsNumber: "",
        goodsPcode69: "",
        goodsSpecs: "",
        kcUnit: "",
        kcNum: "",
    }
};
var HxBasicGoodsInfoDlg = {
    data: {
        id: "",
        goodsCustomerId: "",
        goodsCustomerName: "",
        goodsName: "",
        goodsNumber: "",
        goodsPcode69: "",
        goodsXcode69: "",
        goodsHcode69: "",
        goodsHelpcode: "",
        goodsSpecs: "",
        dismantlingParts: "",
        goodsBigtype: "",
        goodsBrand: "",

        jibenUnit: "",
        kcUnit: "",
        kcRate: "",
        cgUnit: "",
        cgRate: "",
        pfUnit: "",
        pfRate: "",
        psUnit: "",
        psRate: "",

        anquanNum: "",
        goodsBottom: "",
        goodsLamination: "",
        goodsTraylayer: "",
        goodsSupportvolume: "",
        length: "",
        height: "",
        width: "",
        goodsWeight: "",
        goodsVolume: "",
        goodsChargingCg: "",
        goodsChargingPs: "",
        goodsChargingPf: "",
        goodsWarranty: "",
        xlbPositionId: "",
        xlbGoodsId: ""
    }
};

layui.use(['table', 'form', 'admin', 'ax', 'laydate'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var laydate = layui.laydate;
    var table = layui.table;


    laydate.render({
        elem: '#peisongTime'
        , value: new Date()
    });

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    var OrderId = null;

    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/hxStorageManage/addItem", function (data) {
            if (data.success) {
                $('#orderOutNumber').val(data.data.storageNumber);
                OrderId = data.data.id;
                Feng.success("保存成功！已生成单号为：" + data.data.storageNumber);
                $('#btnSubmit').addClass('layui-btn-disabled').attr('disabled', true);
                // window.location.href = Feng.ctxPath + '/hxOrderOut'
                hxStorageOut(data.data);
            } else {
                Feng.error("保存失败！" + data.message);
            }
        }, function (data) {
            Feng.error("添加失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });

    $('#choiceGetUnit').click(function () {
        layer.open({
            type: 2,
            title: '选择收货客户',
            area: ['1000px', '500px'],
            content: Feng.ctxPath + '/basicPutgoods/tochoiceBasicPutgoods_hx',
            end: function () {
                $("#getUnitId").val(BasicPutgoodsInfoDlg.data.id);
                $("#getUnit").val(BasicPutgoodsInfoDlg.data.putgoodsName);
            }
        });

    });

    //返回按钮
    $("#backupPage").click(function () {
        window.location.href = Feng.ctxPath + '/hxStorageManage'
    });

    /**
     * 拣货单明细表管理
     */
    var HxStorageOutDetailed = {
        tableId: "hxStorageOutDetailedTable"
    };

    /**
     * 初始化表格的列
     */
    HxStorageOutDetailed.initColumn = function () {
        return [[
            {field: 'id', hide: true, title: '主键id'},
            {align: 'center', toolbar: '#tableBarDetailed', title: '操作', width: 140},
            {field: 'goodsName', sort: true, title: '商品名称', width: 160},
            {field: 'goodsNumber', sort: true, title: '商品编号'},
            {field: 'goodsPcode69', sort: true, title: '商品码'},
            {field: 'goodsSpecs', sort: true, title: '规格'},
            {
                field: 'unit',
                sort: true,
                title: '单位',
                width: 140,
                templet: function (d) {
                    var productId = d.goodsId;
                    // 默认模板
                    var selectHtml =
                        '<select lay-filter="unit_filter" class="unit-select"><option value="" style="display:none;">加载中...</option></select>';

                    // 同步请求，避免打开时无数据
                    $.ajax({
                        url: `/rest/HxStorageReturn/detailedGoodsId?goodsId=${productId}`,
                        type: 'GET',
                        async: false,
                        success: function (res) {
                            if (res && res.data && res.data.length > 0) {
                                const lists = res.data.map(item => { // 1、遍历lists集合，组成数组
                                    // 1、遍历lists集合中的每个元素（这里是res.data），并为每个元素生成一个新的数组
                                    const unitProps = [item.jibenUnit, item.kcUnit, item.cgUnit, item.pfUnit, item.psUnit];

                                    // 2、使用 Set 结构去除 unitProps 数组中的重复元素，然后再转回数组
                                    // 使用 filter 方法过滤掉数组中的 null 和 undefined 值
                                    const uniqueUnits = [...new Set(unitProps)].filter(unit => unit !== null && unit !== undefined);

                                    // 3、对 uniqueUnits 数组中的每个元素重新映射（map）成一个具有 value 和 label 属性的对象
                                    // 每个对象的 value 和 label 都等于原数组中的元素
                                    return uniqueUnits.map(unit => ({
                                        value: unit,
                                        label: unit
                                    }));
                                });
                                // 将所有子数组中的单位对象展平到一个单一的一维数组中
                                const units = lists.flat();

                                // 映射 units 数组中的每个单位对象为一个 HTML <option> 元素字符串
                                var unitsHtml = units.map(unit => {
                                    // 判断当前单位是否是已选中的单位
                                    var isSelected = unit.value === d.unit ? 'selected' : '';

                                    // 返回一个格式化的 option 字符串，并设置 selected 属性（如果适用）
                                    // 同时设置选项的 display 属性为 none，这可能是为了在初始状态下隐藏这些选项
                                    return `<option value="${unit.value}" ${isSelected} style="display:none;">${unit.label}</option>`;
                                }).join('');

                                // 构建完整的 select 下拉菜单 HTML 字符串
                                selectHtml = `<select lay-filter="unit_filter" class="unit-select">${unitsHtml}</select>`;
                            } else {
                                selectHtml = '<select lay-filter="unit_filter" class="unit-select"><option value="">无可用单位</option></select>';
                            }
                        },
                        error: function (error) {
                            selectHtml = '<select lay-filter="unit_filter" class="unit-select"><option value="">加载失败</option></select>';
                        }
                    });
                    return `<div id="approveUnit_${d.id}">${selectHtml}</div>`;
                }
            },
            {
                field: 'num', sort: true, title: '数量', totalRow: true, edit: 'text',width: 140,
                templet: function (d) {
                    return '<input type="text" autocomplete="off" type="text" placeholder="请输入数量" class="layui-input unit-input" value="' + (d.num || '') + '" />';
                }
            },

            {field: 'jibenUnit', sort: true, title: '基本单位', totalRow: true},
            {field: 'jibenNum', sort: true, title: '基本数量', totalRow: true},

            {
                field: 'presentUnit', sort: true, title: '赠品单位', totalRow: true,width: 140,
                templet: function (d) {
                    var productId = d.goodsId;
                    // 默认模板
                    var selectHtml =
                        '<select lay-filter="presentUnit_filter" class="present-unit-select"><option value="" style="display:none;">加载中...</option></select>';

                    // 同步请求，避免打开时无数据
                    $.ajax({
                        url: `/rest/HxStorageReturn/detailedGoodsId?goodsId=${productId}`,
                        type: 'GET',
                        async: false,
                        success: function (res) {
                            if (res && res.data && res.data.length > 0) {
                                const lists = res.data.map(item => {
                                    const unitProps = [item.jibenUnit, item.kcUnit, item.cgUnit, item.pfUnit, item.psUnit];
                                    const uniqueUnits = [...new Set(unitProps)].filter(unit => unit !== null && unit !== undefined);
                                    return uniqueUnits.map(unit => ({ value: unit, label: unit }));
                                });
                                const units = lists.flat();
                                var unitsHtml = units.map(unit => {
                                    var isSelected = unit.value === d.presentUnit ? 'selected' : '';
                                    return `<option value="${unit.value}" ${isSelected} style="display:none;">${unit.label}</option>`;
                                }).join('');
                                selectHtml = `<select lay-filter="presentUnit_filter" class="present-unit-select">${unitsHtml}</select>`;
                            } else {
                                selectHtml = '<select lay-filter="presentUnit_filter" class="present-unit-select"><option value="">无可用单位</option></select>';
                            }
                        },
                        error: function (error) {
                            selectHtml = '<select lay-filter="presentUnit_filter" class="present-unit-select"><option value="">加载失败</option></select>';
                        }
                    });
                    return `<div id="presentUnit_${d.id}">${selectHtml}</div>`;
                }
            },
            {
                field: 'presentQuantity', sort: true, title: '赠品数量', totalRow: true, edit: 'text',width: 180,
                templet: function (d) {
                    return '<input type="text" autocomplete="off" type="text" placeholder="请输入赠品数量"  class="layui-input unit-input" value="' + (d.presentQuantity || '') + '" />';
                }
            },

            {field: 'basicPresentQuantity', sort: true, title: '赠品基本数量', totalRow: true,width: 120},

            {
                field: 'detailedDate', sort: true, title: '生产日期', edit: 'text', width: 180,
                templet: function (d) {
                    return '<input type="text" autocomplete="off" type="text" placeholder="请输入生产日期"  class="layui-input unit-input" value="' + (d.detailedDate || '') + '" />';
                }
            },
            {field: 'daoqiDate', sort: true, title: '到期日期', width: 180},

            {
                field: 'positionNumber', sort: true, title: '出库库位', edit: 'text', width: 170,
                templet: function (d) {
                    // return '<input type="text" autocomplete="off" class="layui-input unit-input" placeholder="请输入库位" value="' + (d.positionNumber || '') + '" />'

                    return '<input type="text" autocomplete="off" class="layui-input unit-input" style="width: calc(100% - 30px);" ' +
                        'placeholder="请输入库位" value="' + (d.positionNumber.trim() || '') + '" />' +
                        '<button type="button" class="layui-btn layui-btn-primary" lay-event="choiceOutPositionNumber" id="choiceOutPositionNumber" ' +
                        'style="position: absolute; right: 1px;cursor: pointer; top: 2px"><i class="layui-icon">&#xe615;</i></button>';
                },
                // toolbar: '#toolbarPosition'
            },
            {field: 'basicPositionQuantity', sort: true, title: '库位基本数量', totalRow: true,width: 120,},

            {
                field: 'nodes', sort: true, title: '备注', edit: 'text', width: 140,
                templet: function (d) {
                    return '<input type="text" autocomplete="off" type="text" placeholder="请输入备注" class="layui-input unit-input" value="' + (d.nodes || '') + '" />';
                }
            },
            {field: 'v2', sort: true, title: '出库时间', width: 160},
        ]];
    };

    // 单元格编辑
    table.on('edit(' + HxStorageOutDetailed.tableId + ')', function (obj) {
        let field = obj.field;
        let value = obj.value;
        let data = obj.data;
        console.log("edit:", data);
        $.ajax({
            url: Feng.ctxPath + '/hxStorageManage/editItem',
            type: 'POST',
            dataType: 'json',
            data: {
                id: data.id,
                // 加 [] 定义属性名
                [field]: value,
                goodsId: data.goodsId,
                goodsNumber: data.goodsNumber,
                unit: data.unit,
                presentUnit: data.presentUnit,
                presentQuantity: data.presentQuantity,
                storageNumber: data.storageNumber
            },
            success: function (res) {
                layer.msg(res.message);
                HxStorageOutDetailed.search();
            },
            error: function (err) {
                layer.msg(err.message);
            }
        });
        // 更新表格数据
        obj.update({
            [field]: value
        });
    });

    function hxStorageOut(data) {
        var setWarehouseId = data.setWarehouseId;

        var storageNumber;
        if (data != null) {
            storageNumber = data.storageNumber;
        } else {
            storageNumber = '0';
        }

        // 渲染商品明细表格
        var detailTable = table.render({
            elem: '#' + HxStorageOutDetailed.tableId,
            url: Feng.ctxPath + '/hxStorageOutDetailed/list?storageNumber=' + storageNumber,
            page: true,
            limit: 30,
            height: 400,
            toolbar: '#toolbarfromDetailed',
            cellMinWidth: 100,
            totalRow: true,//开启合计行
            cols: HxStorageOutDetailed.initColumn(),
            done: function (res, curr, count) {
                var options = this;

                // 获取当前行数据 - 自定义方法
                table.getRowData = function (tableId, elem) {
                    var index = $(elem).closest('tr').data('index');
                    return table.cache[tableId][index] || {};
                };

                form.on('select(unit_filter)', function (obj) {
                    var value = obj.value;
                    var data = table.getRowData(options.id, obj.elem);

                    $.ajax({
                        url: Feng.ctxPath + '/hxStorageManage/editItem',
                        type: 'POST',
                        dataType: 'json',
                        data: {
                            id: data.id,
                            storageNumber: data.storageNumber,
                            goodsId: data.goodsId,
                            goodsNumber: data.goodsNumber,
                            presentUnit: data.presentUnit,
                            presentQuantity: data.presentQuantity,
                            unit: value,
                        },
                        success: function (res) {
                            layer.msg(res.message);
                            HxStorageOutDetailed.search();
                        },
                        error: function (err) {
                            layer.msg(err.message);
                        }
                    });
                });

                form.on('select(presentUnit_filter)', function (obj) {
                    var value = obj.value;
                    var data = table.getRowData(options.id, obj.elem);

                    $.ajax({
                        url: Feng.ctxPath + '/hxStorageManage/editItem',
                        type: 'POST',
                        dataType: 'json',
                        data: {
                            id: data.id,
                            storageNumber: data.storageNumber,
                            goodsId: data.goodsId,
                            goodsNumber: data.goodsNumber,
                            unit: data.unit,
                            presentQuantity: data.presentQuantity,
                            presentUnit: value,
                        },
                        success: function (res) {
                            layer.msg(res.message);
                            HxStorageOutDetailed.search();
                        },
                        error: function (err) {
                            layer.msg(err.message);
                        }
                    });
                });

            }
        });

        /**
         * 点击查询按钮
         */
        HxStorageOutDetailed.search = function () {
            var queryData = {};
            queryData['condition'] = $("#condition2").val();
            table.reload(HxStorageOutDetailed.tableId, {
                where: queryData, page: {curr: 1},
                done: function () {
                    // 搜索按钮点击事件
                    $('#btnSearchDetailed').click(function () {
                        HxStorageOutDetailed.search();
                    });
                    $('#btnAddDetailed').click(function () {
                        HxStorageOutDetailed.addDetailed();
                    });
                }
            });
        };

        /*        HxStorageOutDetailed.addDetailed = function () {
                    layer.open({
                        type: 2,
                        title: '明细录入',
                        area: ['1050px', '750px'],
                        anim: 5,
                        content: Feng.ctxPath + '/hxStorageManage/add2?storageNumber=' + storageNumber,
                        end: function () {
                            hxStorageOut(data);
                        }
                    });
                };*/

        HxStorageOutDetailed.addDetailed = function () {
            layer.open({
                type: 2,
                title: '选择商品',
                area: ['1000px', '450px'],
                content: Feng.ctxPath + '/hxStorageManage/toChoiceGoods_od',
                end: function () {
                    // 请求参数
                    var formData = {
                        storageNumber: storageNumber,
                        jibenUnit: HxBasicGoodsInfoDlg.data.jibenUnit,
                        xlbGoodsId: HxBasicGoodsInfoDlg.data.xlbGoodsId,
                        xlbPositionId: HxBasicGoodsInfoDlg.data.xlbPositionId,
                        goodsId: HxBasicGoodsInfoDlg.data.id,
                        goodsName: HxBasicGoodsInfoDlg.data.goodsName,
                        goodsNumber: HxBasicGoodsInfoDlg.data.goodsNumber,
                        goodsPcode69: HxBasicGoodsInfoDlg.data.goodsPcode69,
                        goodsXcode69: HxBasicGoodsInfoDlg.data.goodsXcode69,
                        goodsHcode69: HxBasicGoodsInfoDlg.data.goodsHcode69,
                        goodsSpecs: HxBasicGoodsInfoDlg.data.goodsSpecs,
                        dismantlingParts: HxBasicGoodsInfoDlg.data.dismantlingParts,
                        unit: HxBasicGoodsInfoDlg.data.psUnit,
                        presentUnit: HxBasicGoodsInfoDlg.data.psUnit,
                        presentRatio: HxBasicGoodsInfoDlg.data.psRate,
                        rate: HxBasicGoodsInfoDlg.data.psRate,
                        goodsVolume: HxBasicGoodsInfoDlg.data.goodsVolume,
                        goodsWeight: HxBasicGoodsInfoDlg.data.goodsWeight,
                        goodsChargingPs: HxBasicGoodsInfoDlg.data.goodsChargingPs
                    };

                    // 判断配送换算率和采购换算率的关系，并计算配送体积和重量
                    if (parseFloat(HxBasicGoodsInfoDlg.data.psRate) == parseFloat(HxBasicGoodsInfoDlg.data.cgRate)) {
                        formData.goodsVolume = accDiv(HxBasicGoodsInfoDlg.data.goodsVolume, 1); // 假设除以1是为了示例
                        formData.goodsWeight = accDiv(HxBasicGoodsInfoDlg.data.goodsWeight, 1);
                    } else if (parseFloat(HxBasicGoodsInfoDlg.data.psRate) < parseFloat(HxBasicGoodsInfoDlg.data.cgRate)) {
                        var div = accDiv(HxBasicGoodsInfoDlg.data.cgRate, HxBasicGoodsInfoDlg.data.psRate);
                        formData.goodsVolume = accDiv(HxBasicGoodsInfoDlg.data.goodsVolume, div).toFixed(4);
                        formData.goodsWeight = accDiv(HxBasicGoodsInfoDlg.data.goodsWeight, div).toFixed(3);
                    } else {
                        var mul = accMul(HxBasicGoodsInfoDlg.data.psRate, 1); // 假设乘以1是为了示例
                        formData.goodsVolume = accMul(HxBasicGoodsInfoDlg.data.goodsVolume, mul).toFixed(4);
                        formData.goodsWeight = accMul(HxBasicGoodsInfoDlg.data.goodsWeight, mul).toFixed(3);
                    }
                    if (formData.goodsId == null || formData.goodsId == '') {
                        // Feng.error("未选择商品！");
                        return;
                    }
                    // 发送 AJAX 请求
                    $.ajax({
                        url: Feng.ctxPath + '/hxStorageManage/addDetailedItem',
                        type: 'POST',
                        dataType: 'json',
                        data: formData,
                        success: function (data) {
                            // 处理响应数据
                            if (data.success) {
                                Feng.success("添加成功！");
                                // parent.layer.close(Index);
                                // table.reload(HxStorageOut.tableId);
                                HxStorageOutDetailed.search();
                                HxBasicGoodsInfoDlg = {
                                    data: {}
                                }
                            } else {
                                Feng.error("保存失败！" + data.message);
                                // table.reload(HxStorageOut.tableId);
                                HxStorageOutDetailed.search();
                                HxBasicGoodsInfoDlg = {
                                    data: {}
                                }
                            }
                        },
                        error: function (data) {
                            Feng.error("添加失败！" + data.responseJSON.message);
                            HxBasicGoodsInfoDlg = {
                                data: {}
                            }
                        }
                    });
                }
            });
        };


        //乘以的精确结果
        function accMul(arg1, arg2) {
            var m = 0, s1 = arg1.toString(),
                s2 = arg2.toString();
            try {
                m += s1.split(".")[1].length
            } catch (e) {
            }
            try {
                m += s2.split(".")[1].length
            } catch (e) {
            }
            return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m
            )
        };

        function accDiv(arg1, arg2) {
            var t1 = 0, t2 = 0, r1, r2;
            try {
                t1 = arg1.toString().split(".")[1].length;
            } catch (e) {
            }

            try {
                t2 = arg2.toString().split(".")[1].length;
            } catch (e) {
            }

            with (Math) {
                r1 = Number(arg1.toString().replace(".", ""));
                r2 = Number(arg2.toString().replace(".", ""));
                return (r1 / r2) * pow(10, t2 - t1);
            }
        };

        // 工具条点击事件
        table.on('tool(' + HxStorageOutDetailed.tableId + ')', function (obj) {
            var data2 = obj.data;
            var layEvent = obj.event;

            if (layEvent === 'deleteDetailed') {
                HxStorageOutDetailed.onDeleteItem(data2);
            }
            if (layEvent === 'choiceOutPositionNumber') {
                HxStorageOutDetailed.choiceOutPositionNumber(data2);
            }
        });

        /**
         * 选择库位
         * @param data2
         */
        HxStorageOutDetailed.choiceOutPositionNumber = function (data2) {
            layer.open({
                type: 2,
                title: '选择转出库位',
                area: ['1100px', '560px'],
                content: Feng.ctxPath + '/hxStorageManage/tochoiceStorageStock?warehouseId=' + setWarehouseId + '&goodsId=' + data2.goodsId,
                end: function () {
                    var positionNumber = HxStorageStockInfoDlg.data.positionNumber;
                    if (positionNumber == null || positionNumber == '') {
                        return;
                    }
                    var ajax = new $ax(Feng.ctxPath + "/hxStorageManage/editItem", function (res) {
                        // 确保这里定义了success回调函数
                        layer.msg(res.message);
                        // hxStorageOut(res.data);
                        HxStorageOutDetailed.search();
                        HxStorageStockInfoDlg = {
                            data: {}
                        }
                    }, function (err) {
                        // 确保这里定义了error回调函数
                        layer.msg(err.message);
                        HxStorageOutDetailed.search();
                        HxStorageStockInfoDlg = {
                            data: {}
                        }
                    });
                    ajax.setData({
                        "id": data2.id,
                        "positionNumber": HxStorageStockInfoDlg.data.positionNumber,
                        "goodsId": data2.goodsId,
                        "goodsNumber": data2.goodsNumber,
                        "storageNumber": data2.storageNumber
                    });
                    ajax.start();
                }
            });
        };

        // 删除按钮点击事件
        HxStorageOutDetailed.onDeleteItem = function (data2) {
            var operation = function () {
                var ajax = new $ax(Feng.ctxPath + "/hxStorageOutDetailed/delete", function (data2) {
                    Feng.success("删除成功!");
                    hxStorageOut(data);
                }, function (data) {
                    Feng.error("删除失败!" + data2.responseJSON.message + "!");
                });
                ajax.set("id", data2.id);
                ajax.start();
            };
            Feng.confirm("是否删除?", operation);
        };

        /**
         * 点击批量完成
         */
        /* HxStorageOut.btnFinish = function () {
             console.log("审核按钮")
             var checkStatus = table.checkStatus('hxStorageOutTable');
             data = checkStatus.data;

             if (data.length > 0) {
                 var ids = [];
                 for (var i = 0; i < data.length; i++) {
                     ids.push(data[i].id);
                 }
                 var operation = function () {
                     var ajax = new $ax(Feng.ctxPath + "/hxStorageManage/finish?ids=" + OrderId, function (data) {
                         console.log("resData,", data)
                         Feng.success(data.message);
                         table.reload(HxStorageOut.tableId);
                     }, function (data) {
                         console.log("errData,", data)
                         Feng.error("审核!" + data.responseJSON.message + "!");
                     });
                     ajax.start();
                 };
                 Feng.confirm("是否审核选中订单?", operation);
             } else {
                 layer.alert('请至少选中一条数据');
             }
         };*/

        /**
         * 点击批量完成
         */
        $('#btnFinish').click(function () {
            var ids = [];
            ids.push(OrderId)
            var operation = function () {
                var ajax = new $ax(Feng.ctxPath + "/hxStorageManage/finish?ids=" + ids, function (data) {
                    console.log("resData,", data)
                    Feng.success(data.message);
                    window.location.href = Feng.ctxPath + '/hxStorageManage'
                }, function (data) {
                    console.log("errData,", data)
                    Feng.error("审核!" + data.responseJSON.message + "!");
                });
                ajax.start();
            };
            Feng.confirm("是否审核该订单?", operation);
        });


        // 搜索按钮点击事件
        $('#btnSearchDetailed').click(function () {
            HxStorageOutDetailed.search();
        });

        $('#btnAddDetailed').click(function () {
            HxStorageOutDetailed.addDetailed();
        });
    }


});